import { Channel, ChannelAction } from '../actions/channel'

type ChannelType = {
  channelList: Channel[]
  active: number
}
const initValue: ChannelType = {
  channelList: [],
  active: 0
}

export default function channel(
  state = initValue,
  action: ChannelAction
): ChannelType {
  if (action.type === 'channel/getChannelList') {
    return {
      ...state,
      channelList: action.payload
    }
  }
  if (action.type === 'channel/changeActive') {
    return {
      ...state,
      active: action.payload
    }
  }
  return state
}
